package evolution.problem;

public class BeckerLagoMinimization extends AbstractMinimizationProblem {

	public static final ProblemConstraints CONSTRAINTS = new ProblemConstraints(
			2, -10, 10);

	public BeckerLagoMinimization() {
		super(CONSTRAINTS);
	}

	@Override
	public double getValue(double[] x) {
		int dimensions = x.length;
		double sum = 0;

		for (int i = 0; i < dimensions; i++) {
			double part = Math.abs(x[i]) - 5;
			sum += part * part;
		}

		return sum;
	}

	@Override
	public String getGnuplotFunction() {
		return "(abs(x)-5)**2 + (abs(y)-5)**2";
	}

	@Override
	public String getGnuplotFunctionName() {
		return "becker_and_lago";
	}

}
